/*     */ package com.zimbra.cs.service.admin;
/*     */ 
/*     */ import com.zimbra.common.account.Key.DistributionListBy;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.Group;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*     */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*     */ import com.zimbra.soap.ZimbraSoapContext;
/*     */ import com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse;
/*     */ import java.util.Arrays;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Set;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class RemoveDistributionListMember
/*     */   extends ReloadMemberPostProxyHandler
/*     */ {
/*     */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*     */   {
/*  45 */     return true;
/*     */   }
/*     */   
/*     */   protected List<String> getMemberList(Element request, Map<String, Object> context)
/*     */     throws ServiceException
/*     */   {
/*  51 */     List<String> memberList = super.getMemberList(request, context);
/*  52 */     Group group = getGroupFromContext(context);
/*  53 */     memberList = addMembersFromAccountElements(request, memberList, group);
/*  54 */     return memberList;
/*     */   }
/*     */   
/*     */   private List<String> addMembersFromAccountElements(Element request, List<String> memberList, Group group) throws ServiceException {
/*  58 */     Provisioning prov = Provisioning.getInstance();
/*  59 */     for (Element elem : request.listElements("account")) {
/*  60 */       listAddresses = group.getAllMembersSet();
/*  61 */       Account account = prov.getAccount(elem.getTextTrim());
/*  62 */       if (account != null) {
/*  63 */         if (listAddresses.contains(account.getMail())) {
/*  64 */           memberList.add(account.getMail());
/*     */         }
/*  66 */         List<String> accountAddresses = Arrays.asList(account.getAliases());
/*  67 */         for (String addr : accountAddresses) {
/*  68 */           if (listAddresses.contains(addr))
/*  69 */             memberList.add(addr);
/*     */         }
/*     */       }
/*     */     }
/*     */     Set<String> listAddresses;
/*  74 */     return memberList;
/*     */   }
/*     */   
/*     */   public Element handle(Element request, Map<String, Object> context)
/*     */     throws ServiceException
/*     */   {
/*  80 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*  81 */     Provisioning prov = Provisioning.getInstance();
/*     */     
/*  83 */     List<String> memberList = getMemberList(request, context);
/*     */     
/*  85 */     Group group = getGroupFromContext(context);
/*  86 */     String id = request.getAttribute("id");
/*  87 */     defendAgainstGroupHarvesting(group, Key.DistributionListBy.id, id, zsc, Rights.Admin.R_removeGroupMember, Rights.Admin.R_removeDistributionListMember);
/*     */     
/*     */ 
/*  90 */     memberList = addMembersFromAccountElements(request, memberList, group);
/*     */     
/*  92 */     String[] members = (String[])memberList.toArray(new String[0]);
/*  93 */     prov.removeGroupMembers(group, members);
/*     */     
/*  95 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RemoveDistributionListMember", "name", group.getName(), "member", Arrays.deepToString(members) }));
/*     */     
/*     */ 
/*  98 */     return zsc.jaxbToElement(new RemoveDistributionListMemberResponse());
/*     */   }
/*     */   
/*     */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*     */   {
/* 103 */     relatedRights.add(Rights.Admin.R_removeDistributionListMember);
/* 104 */     relatedRights.add(Rights.Admin.R_removeGroupMember);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/RemoveDistributionListMember.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */